package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Detectitem;
import com.ruoyi.system.service.IDetectitemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检测数据Controller
 * 
 * @author gzhuangwei
 * @date 2022-09-17
 */
@RestController
@RequestMapping("/business/detectitem")
public class DetectitemController extends BaseController
{
    @Autowired
    private IDetectitemService detectitemService;

    /**
     * 查询检测数据列表
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(Detectitem detectitem)
    {
        startPage();
        List<Detectitem> list = detectitemService.selectDetectitemList(detectitem);
        return getDataTable(list);
    }

    /**
     * 导出检测数据列表
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:export')")
    @Log(title = "检测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Detectitem detectitem)
    {
        List<Detectitem> list = detectitemService.selectDetectitemList(detectitem);
        ExcelUtil<Detectitem> util = new ExcelUtil<Detectitem>(Detectitem.class);
        util.exportExcel(response, list, "检测数据数据");
    }

    /**
     * 获取检测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(detectitemService.selectDetectitemById(id));
    }

    /**
     * 新增检测数据
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:add')")
    @Log(title = "检测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Detectitem detectitem)
    {
        return toAjax(detectitemService.insertDetectitem(detectitem));
    }

    /**
     * 修改检测数据
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:edit')")
    @Log(title = "检测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Detectitem detectitem)
    {
        return toAjax(detectitemService.updateDetectitem(detectitem));
    }

    /**
     * 删除检测数据
     */
    @PreAuthorize("@ss.hasPermi('business:detectitem:remove')")
    @Log(title = "检测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(detectitemService.deleteDetectitemByIds(ids));
    }
}
